<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>查询结果页面</title>
</head>
<body>
<table border="1">

<?php

if(isset($_POST['sub'])){
	$idea = $_POST['idea'];
	$housetype = $_POST['housetype'];
	$style = $_POST['style'];
	$app = $_POST['app'];
	$price = $_POST['price'];
	$pubdate = $_POST['pubdate'];
	//$area = $_POST['area'];

	$conn = mysql_connect("localhost","root","root");
	mysql_select_db("case");
	$query = "select * from `case` where `idea`='".$idea."'";
	
	if($housetype !=""){
		$query .=" && `housetype`='".$housetype."'";
	}
	if($style !=""){
		$query .=" && `style`='".$style."'";
	}
	if($app !=""){
		$query .=" && `app`='".$app."'";
	}
	if($price !=""){
		switch($price){
			case "A":
			$query.=" && `price`<'50000'";
			break;
			case "B":
			$query.=" && `price`>='50000'";
		}
	}
	switch($pubdate){
		case "A":
		$query.=" && TO_DAYS(NOW()) - TO_DAYS(`pubdate`)<=7";
		break;
		case "B":
		$query.=" && TO_DAYS(NOW()) - TO_DAYS(`pubdate`)<=30";
		break;
		case "C":
		$query.=" && TO_DAYS(NOW()) - TO_DAYS(`pubdate`)<=91";
		break;
		case "D":
		$query.=" && TO_DAYS(NOW()) - TO_DAYS(`pubdate`)<=183";		
		break;
	}

	//执行查询语句
	$query = $query." ORDER BY `pid` limit 0,20;";
	//echo $query;
	@mysql_query("SET NAMES 'utf8'",$conn);
	$result = mysql_query($query,$conn);
	if($result){
		$rows = mysql_num_rows($result);
		if($rows!=0){
			while($myrow = mysql_fetch_array($result)){
				echo "<tr>";
				echo "<td width='15' height='12'><input name='tl' type='radio' value='' /></td>";
				echo "<td width='640' height='12'>$myrow[pid]&nbsp;$myrow[idea]&nbsp;&nbsp;$myrow[style]($myrow[housetype])<font style='font-size:12px'>$myrow[pubdate]</font>";
				echo "</td>";
				echo "<td width='100' height='12'><a href='' target='_blank'>详细信息</a></td>";
				echo "</tr>";
			}
		}else{
			echo "您搜索的类型不在，请重新查找<a href='house.html'>请点击返回</a>";
		}
	}
}

?>
</table>
</body>
</html>